package com.ruoyi.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.OrderPaymentVO;
import com.ruoyi.domain.OrdersPaymentDTO;
import com.ruoyi.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 订单
 */
@RestController("userOrderController")
@RequestMapping("/user/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 订单支付
     *
     * @param ordersPaymentDTO
     * @return
     */
    @PutMapping("/payment")
    public AjaxResult payment(@RequestBody OrdersPaymentDTO ordersPaymentDTO) throws Exception {
        log.info("订单支付：{}", ordersPaymentDTO);
        ordersPaymentDTO.setOrderNumber("1234567811");
        ordersPaymentDTO.setPayMethod(1);
//        OrderPaymentVO orderPaymentVO = new OrderPaymentVO();
//        orderPaymentVO.setNonceStr("sdf");
        OrderPaymentVO orderPaymentVO = orderService.payment(ordersPaymentDTO);
        log.info("生成预支付交易单：{}", orderPaymentVO);
        return AjaxResult.success(orderPaymentVO);
    }

}
